package com.anonymous.model;

import java.security.cert.X509Certificate;

import javax.swing.table.AbstractTableModel;

public class UserListTableModel extends AbstractTableModel {

	private static final long serialVersionUID = 1L;
	String[] columnNames = { "Username", "Certificate", "IP" };

	private Object[][] data;

	public int getIndexFromName(String name) throws Exception{
		for(int n = 0; n < getColumnCount(); n++){
			if(((String)data[n][0]).equals(name)){
				return n;
			}
		}
		throw new Exception("No User founded!");
	}
	
	public UserListTableModel(Object[][] data) {
		this.data = data;
	}

	public int getColumnCount() {
		return columnNames.length;
	}

	public int getRowCount() {
		if (data == null)
			return 0;
		else
			return data.length;
	}

	public String getColumnName(int col) {
		return columnNames[col];
	}

	public Object getValueAt(int row, int col) {

		return data[row][col];
	}

}